<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>更改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>

    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/js/index.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <style>
        .layui-form {
            padding: 20px 50px;
        }
    </style>
</head>
<body>
<form class="layui-form layui-form-pane">
    <div class="layui-form-item" lay-filter="bill-form">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="required" placeholder="请输入用户名" autocomplete="off"
                   class="layui-input" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">原密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" lay-verify="required" placeholder="请输入密码"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-block">
            <input type="password" name="newPassword" lay-verify="required" placeholder="请输入新密码"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认新密码</label>
        <div class="layui-input-block">
            <input type="password" name="reNewPassword" lay-verify="required" placeholder="请确认新密码"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="update" style="margin-left: 0;">
            立即提交
        </button>
        <button type="reset" id="resetForm" style="display: none;">重置</button>
    </div>
</form>
<script>
    $("input[name=username]").val(parent.sessionUser.username);
    $("input[name=id]").val(parent.sessionUser.id);
    $(function  () {
        layui.use('form', function(){
            var form = layui.form;
            // layer.msg('玩命卖萌中', function(){
            //   //关闭后的操作
            //   });
            //监听提交
            form.on('submit(update)', function(data){
                $.post("/user/password/change",data.field,function(res){
                    if(res.code == 200){
                        layer.msg("密码修改成功，正在跳转到登录页面...",{time:800},function () {
                            top.location.href='/logout';
                        });
                    }else {
                        layer.msg(res.msg)
                    }
                },"json");
                return false;
            });
        });
    })
</script>
</body>
</html>
